package com.joysuch.wwyt.workflow.controller;


import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.workflow.bean.WorkFlowInquiryConfigBean;
import com.joysuch.wwyt.workflow.bean.WorkFlowInquirySerachParam;
import com.joysuch.wwyt.workflow.service.BaseSummaryInquiryConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhaoqw
 * @since 2021-04-16
 */
@RestController
@Api(tags = "报表统计")
@RequestMapping("/workflow/base-summary-inquiry-config")
public class BaseSummaryInquiryConfigController {

    @Autowired
    private BaseSummaryInquiryConfigService configService;

    @PostMapping("save")
    @ApiOperation("保存报表统计")
    @RequiresPermissions("workflow:inquiry:save")
    public ResultBean save(@Valid @RequestBody WorkFlowInquiryConfigBean dto) {
        configService.saveSummaryInquiryConfig(dto);
        return ResultBean.success("");
    }

    @GetMapping("findById")
    @ApiOperation("查看报表统计")
    public ResultBean findById(Long id) {
        WorkFlowInquiryConfigBean dto = configService.findById(id);
        return ResultBean.success(dto);
    }

    @PostMapping("page")
    @ApiOperation("分页查询")
    public ResultBean page(@Valid @RequestBody WorkFlowInquirySerachParam param) {
        return configService.findPage(param);
    }

    @GetMapping("deleteById")
    @ApiOperation("删除")
    @RequiresPermissions("workflow:inquiry:delete")
    public ResultBean deleteById(Long id) {
        return configService.deleteById(id);
    }
}

